package exercise5;
import java.util.Scanner;

public class MinIndex extends BaseExample{
//	返回一个整数数组中最小值的位置
	public static int minIndex(int[] list) {
		int location = 0;
		int min = list[0];
		for (int i = 1; i < list.length; ++i) {
			if (list[i] < min) {
				min = list[i];
				location = i;
			}
		}
		return location + 1;
	}
	public void minLocation() {
		this.logger.debug("请输入数组个数n:");
		@SuppressWarnings("resource")
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		this.logger.debug("请输入各位数字：");
		for (int i = 0; i < a.length; i++)
			a[i] = in.nextInt();
		this.logger.debug("最小的数字位置为：" + minIndex(a));
	}

}
